/*
* Copyright (c) 2007 by Kirill Kolodyazhniy.
* See the file "license.terms" for information on usage and redistribution.
*/

#include "movableobject.h"

namespace Engine
{
	/**********************************************************************************************************/
	MovableObject::MovableObject(const std::string& name)
		:m_name(name)
		,m_parentNode(NULL)
        ,m_visible(false)
		,m_renderingDistance(0.0)
		,m_castShadows(true)
	{
	}
	/**********************************************************************************************************/
    MovableObject::~MovableObject()
	{
	}
	/**********************************************************************************************************/
	const std::string& MovableObject::GetName()const
	{
		return m_name;
	}
	/**********************************************************************************************************/
	void MovableObject::SetVisible(bool visible)
	{
		m_visible = visible;
	}
	/**********************************************************************************************************/
    bool MovableObject::IsVisible(void) const
	{
		return m_visible;
	}
	/**********************************************************************************************************/
	void MovableObject::SetRenderingDistance(REAL dist)
	{
		m_renderingDistance = dist;
	}
	/**********************************************************************************************************/
	REAL MovableObject::GetRenderingDistance(void) const
	{
		return m_renderingDistance;
	}
	/**********************************************************************************************************/
    SceneNode* MovableObject::GetParentNode(void) const
	{
		return m_parentNode;
	}
	/**********************************************************************************************************/
    bool MovableObject::IsAttached(void) const
	{
		return m_parentNode != NULL;
	}
	/**********************************************************************************************************/
    void MovableObject::NotifyAttached(SceneNode* parent)
	{
		m_parentNode = parent;
	}
	/**********************************************************************************************************/
    void MovableObject::NotifyDetached()
	{
		m_parentNode = 0;
	}
	/**********************************************************************************************************/
	const AABB& MovableObject::GetWorldBoundingBox(void) const
	{
		m_worldAABB = GetBoundingBox();
		m_worldAABB.Transform(m_parentNode->GetDerivedTransform());
		return m_worldAABB;
	}
	/**********************************************************************************************************/
	bool MovableObject::IsCastShadow() const
	{
		return m_castShadows;
	}
	/**********************************************************************************************************/
	void MovableObject::SetCastShadow(bool val)
	{
		m_castShadows = val;
	}
	/**********************************************************************************************************/

}
